package com.example.shorg.controller;

import com.example.shorg.dto.OrderDTO;
import com.example.shorg.enums.ResultEnum;
import com.example.shorg.exception.ShorgException;
import com.example.shorg.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/pay")
@Slf4j
public class PayController {

    @Autowired
    private OrderService service;

    @GetMapping("/create")
    public void create(@RequestParam("orderId") String orderId, @RequestParam("returnUrl") String returnUlr){

        //1、查询订单
        OrderDTO orderDTO = service.findOne(orderId);
        if(orderDTO == null){
            log.error("【支付模块】  订单不存在");
            throw new ShorgException(ResultEnum.ORDER_NOT_EXIST);
        }
    }
}
